package com.kwt.learn.array;

/**
 * 引用类型数据内存分配
 */
public class Array03 {
    public static void main(String[] args) {
        //1.声明一个person数组
        Person[] persons;
        //2、初始化赋值
        persons = new Person[2];
        //3、new 一个 张三/李四
        Person zhangsan = new Person("zhangsan", 12);
        Person lisi = new Person("lisi", 14);
        //4 将张三放入数组
        persons[0] = zhangsan;
        persons[1] = lisi;
        System.out.println(zhangsan);
        System.out.println(persons[0]);
        //5、改变张三年龄
        zhangsan.setAge(20);

        //6输出张三和
        System.out.println("zhangsan修改年龄以后--------------------------------");
        System.out.println(zhangsan);
        System.out.println(persons[0]);

    }
}
